package com.lsh.oms.provider.service.rpc;

import com.alibaba.dubbo.config.annotation.Service;
import com.lsh.base.common.model.CommonResult;
import com.lsh.oms.api.service.order.IOrderPoRpcService;
import com.lsh.oms.core.enums.TaskStatus;
import com.lsh.oms.core.enums.TaskType;
import com.lsh.oms.core.model.po.OmsTask;
import com.lsh.oms.core.service.po.OmsTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Project Name: lsh-oms
 *
 * @author peter
 * @date 18/6/23
 * 北京链商电子商务有限公司
 * Package
 * desc:
 */
@Service(protocol = "dubbo", validation = "true", timeout = 10000)
@Slf4j
@Deprecated
public class OrderDealRpcServiceImpl implements IOrderPoRpcService {

    @Autowired
    private OmsTaskService omsTaskService;


    /**
     * @param orderCode
     * @param venderId
     * @return
     */
    @Override
    public CommonResult<String> addPoTask(Long orderCode, Long venderId) {

        try {
            Integer timestamp = (int) (System.currentTimeMillis() / 1000);

            OmsTask omsTask = new OmsTask();
            omsTask.setRefCode(orderCode + "");
            omsTask.setContent(orderCode + "");
            omsTask.setTaskStatus(TaskStatus.TASK_UN_DEAL.getCode());
            omsTask.setTaskType(TaskType.ORDER_REICEPT_PO_SO_PSI.getCode());
            omsTask.setExecCount(0);
            omsTask.setCreateTime(timestamp);
            omsTask.setUpdateTime(timestamp);
            omsTask.setVenderId(venderId);

            omsTaskService.add(omsTask);
        } catch (Exception e) {
            log.error("添加任务失败", e);
        }
        return CommonResult.success("ok", "success");
    }
}
